package entity;

import service.CallService;
import service.NetService;
import service.SendService;

public class SuperPackage extends ServicePackage implements SendService,CallService,NetService{
	private int talkTime;//通话时长
	private int smsCount;//短信条数
	private int flow;//上网流量
	
	
	
	public int getTalkTime() {
		return talkTime;
	}

	public SuperPackage(double price, int talkTime, int smsCount, int flow) {
		super(price);
		this.talkTime = talkTime;
		this.smsCount = smsCount;
		this.flow = flow;
	}

	public SuperPackage() {
		super();
		// TODO Auto-generated constructor stub
		this.talkTime = 200;
		this.smsCount = 50;
		this.flow = 1*1024;  
		this.price = 78.0;
	}



	public SuperPackage(double price) {
		super(price);
		// TODO Auto-generated constructor stub
	}



	public int getSmsCount() {
		return smsCount;
	}



	public void setSmsCount(int smsCount) {
		this.smsCount = smsCount;
	}



	public int getFlow() {
		return flow;
	}



	public void setFlow(int flow) {
		this.flow = flow;
	}



	@Override
	public void showInfo() {
		// TODO Auto-generated method stub
		System.out.println("超人套餐： 通话时间："+talkTime+"分钟　　短信："+smsCount+"条　　流量："+flow+"MB");
	}

	public int netPlay(int flow, MobileCard card) {
		// TODO Auto-generated method stub
		for (int i = 0; i < flow; i++) {
			if(card.getRealFlow()<=this.flow) {
				card.setRealFlow(card.getRealFlow()+1);
			}else if(card.getRealFlow()>this.getFlow()) {
			
				card.setAonsumAmount(card.getAonsumAmount()-0.1);
			}
		}
		return 0;
	}

	public int call(int minCount, MobileCard card) {
		// TODO Auto-generated method stub
		for (int i = 0; i < minCount; i++) {
			if(card.getRealTalkTime()<=this.talkTime) {
				card.setRealTalkTime(card.getRealTalkTime()+1);
			}else if(card.getRealTalkTime()>this.getTalkTime()) {
			
				card.setAonsumAmount(card.getAonsumAmount()-0.2);
			}
		}
		return 0;
	}

	public int send(int count, MobileCard card) {
		// TODO Auto-generated method stub
		for (int i = 0; i < count; i++) {
			if(card.getRealSMSCount()<=this.smsCount) {
				card.setRealSMSCount(card.getRealSMSCount()+1);
			}else if(card.getRealSMSCount()>this.getSmsCount()) {
			
				card.setAonsumAmount(card.getAonsumAmount()-0.5);
			}
		}
		return 0;
	}

}
